﻿Module VariablesModule

#Region "Moving Form Variables"
    ''Const's for moving the form with SPI method
    Public WM_NCHITTEST As Integer = 132
    Public HTCLIENT As Integer = 1
    Public HTCAPTION As Integer = 2
    Public WM_NCLBUTTONDBLCLK As Integer = 163
#End Region

#Region "WindowerFFXI"
    Public WinDisplay As New WindowerFFXI.Display
    Public WinSend As New WindowerFFXI.SendString
    Public WinInit As New WindowerFFXI.Initialize
    Public WinGet As New WindowerFFXI.GetCmd
#End Region

#Region "Application Settings"
    Public PClient As Integer
#End Region

#Region "Track Information"
    Structure TrackInformation
        Public Artist As String
        Public Title As String
        Public Duration As String
        Public DurationInt As Integer
        Public Possition As String
        Public PossitionINT As Integer
        Public PlayStateSTR As String
        Public PlayStateInt As Integer
        Public wintext As String
    End Structure
    Public WindowerDisplayString As String

    Public STrack As New TrackInformation '' Track information for Standalone player
    Public sPlayerReady As Boolean

    Public WTrack As New TrackInformation '' Track information for Winamp player
    Public wPlayerReady As Boolean
    Public wSplit As Boolean

    Public iTrack As New TrackInformation '' Track information for iIunes player
    Public iPlayerReady

    Public Sub ConvertTimeMS()

        Dim min As Integer
        Dim sec As Integer
        min = (WTrack.PossitionINT / 1000) \ 60
        sec = (WTrack.PossitionINT / 1000) - (min * 60)
        If sec = "-1" Then sec = "0"
        If sec < 10 Then
            WTrack.Possition = min & ":0" & sec
        ElseIf sec >= 10 Then
            WTrack.Possition = min & ":" & sec
        End If
    End Sub

    Public Sub ConvertTimeS()
        Dim min As Integer
        Dim sec As Integer
        min = WTrack.DurationInt \ 60
        sec = WTrack.DurationInt - (min * 60)
        If sec = "-1" Then sec = "0"
        If sec < 10 Then
            WTrack.Duration = min & ":0" & sec
        ElseIf sec >= 10 Then
            WTrack.Duration = min & ":" & sec
        End If
    End Sub

    Public Sub TrackSplit()
        If WTrack.PlayStateInt = 1 Then
            If My.Settings.WinampSplit = 0 Then
                WTrack.Title = WTrack.wintext
            ElseIf My.Settings.WinampSplit = 1 Then
                Dim tmparr() As String
                If WTrack.wintext.Contains("-") Then
                    tmparr = WTrack.wintext.Split("-")
                    WTrack.Artist = tmparr(0)
                    WTrack.Title = tmparr(1)
                    wSplit = True
                Else
                    WTrack.Title = WTrack.wintext
                    wSplit = False
                End If
            ElseIf My.Settings.WinampSplit = 2 Then
                Dim tmparr() As String
                If WTrack.wintext.Contains("|") Then
                    tmparr = WTrack.wintext.Split("|")
                    WTrack.Artist = tmparr(0)
                    WTrack.Title = tmparr(1)
                    wSplit = True
                Else
                    WTrack.Title = WTrack.wintext
                    wSplit = False
                End If

            End If
        End If
    End Sub

#End Region

End Module
